package com.hyc.myvideo.ui.activity.my;

import android.view.View;
import android.widget.RelativeLayout;

import com.acmenxd.toaster.Toaster;
import com.hyc.myvideo.R;
import com.hyc.myvideo.data.api.model.UserInfo;
import com.hyc.myvideo.ui.base.BaseFActivity;
import com.hyc.myvideo.utils.UserTokenCache;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 设置
 * @author gyb
 * @version 1.0
 * @created 2017/07/11
 */
public class SiteActivity extends BaseFActivity {
    @BindView(R.id.quit_id)
    RelativeLayout layout;
    @Override
    public int getContentViewId() {
        return R.layout.activity_site;
    }

    @Override
    protected void initView() {
        setLeftBtnClick(true,getStr(R.string.home_title_site));
    }

    @Override
    protected void initData() {

    }

    @Override public void onResume() {
        super.onResume();
        isLogin();
    }

    private void isLogin(){
        if(userInfo.isLogin()){
            layout.setVisibility(View.VISIBLE);
        }else{
            layout.setVisibility(View.GONE);
        }
    }







    @Override
    protected void oNext(String resulte, String method) {

    }

    @Override
    protected void oError() {

    }

    @OnClick({R.id.r_id,R.id.quit_id})
    public void onClicks(View view) {
        switch (view.getId()){
            /*清除缓存*/
            case R.id.r_id:
                Toaster.show("清除缓存");
                break;
            /*退出登录*/
            case R.id.quit_id:
                UserInfo userInfo = appContext.getUserInfo();
                userInfo.setLogin(false);
                userInfo.clearAllData();
                UserTokenCache.USER_ID.putValue("",appContext);
                UserTokenCache.USER_TOKEN.putValue("",appContext);
                Toaster.show("退出成功");
                this.finish();
                break;
        }
    }

}
